
Introduction
Mapinfo tab to ESRI shapefile converter can convert MapInfo vector tables to the ESRI shape format. It is implemented as a command line interface to IMUT.exe.
Using the Code
This is a code sample, and will only work with Universal Translator Imut files.
char szExeFile[1024];
sprintf(szExeFile, "\"%s\\imut.exe\" CFGenerate "
"MAPINFO SHAPE \"%s/\" hggtemp1.dat LOG_STANDARDOUT YES",
(LPCTSTR)m_strImut,(LPCTSTR)strFilePath);
STARTUPINFO si;
GetStartupInfo( &si );
PROCESS_INFORMATION pi;
si.dwFlags = STARTF_FORCEONFEEDBACK;
si.wShowWindow = SW_HIDE;
if(CreateProcess(NULL,
szExeFile,
NULL,
NULL,
FALSE,
CREATE_DEFAULT_ERROR_MODE,
NULL,
(LPCTSTR)m_strImut,
&si,
&pi))
{
CloseHandle(pi.hThread);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
FILE *fp;
sprintf(szExeFile, "%s\\hggtemp2.dat",(LPCTSTR)m_strImut);
if((fp = fopen(szExeFile, "wt")) != NULL)
{
fprintf( fp, "MACRO _EXTENSION TAB\n");
fprintf( fp, "MACRO SourceDataset %s\n", (LPCTSTR)strFilePath);
fprintf( fp, "MACRO DestDataset %s\n", strDstPath);
fprintf( fp, "INCLUDE hggtemp1.dat\n");
fclose(fp);
sprintf(szExeFile, "\"%s\\imut.exe\" hggtemp2.dat", (LPCTSTR)m_strImut);
if(CreateProcess(NULL,
szExeFile,
NULL,
NULL,
FALSE,
CREATE_DEFAULT_ERROR_MODE,
NULL,
(LPCTSTR)m_strImut,
&si,
&pi))
{
CloseHandle(pi.hThread);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
}
}
}
Points of Interest
The tool can convert a lot of tab files (located in a different directory) to shapefile format. Manual operation is a tiring, trouble thing; it may cause an error.
History
- 18th June, 2006: First release.
- 2nd December, 2010: Updated source code.